#pragma once

// 电池
#include "base_component.h"

class Battery : public BaseComponent {
public:
    Battery();
    void print() override;
    int save(YAML::Node& node) override;
    int setBatteryParams(std::string params);
    void setSupplyVoltage(float voltage);
    void setChargingTime(float time);

private:
    std::string _batteryParams;
    float _supplyVoltage;
    float _chargingTime;
};

namespace YAML {
template <>
struct convert<Battery> {
    static bool decode(const Node& node, Battery& rhs) {
        rhs.setBatteryParams(node["batteryParams"].as<std::string>());
        rhs.setSupplyVoltage(node["supplyVoltage"].as<float>());
        rhs.setChargingTime(node["chargingTime"].as<float>());
        return true;
    }
};
}  // namespace YAML